package com.hy.z.result;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private Integer code;
    private String msg;
    private Object data;

    public Result(ReInter reInter, Object data) {
        this.code = reInter.code();
        this.msg = reInter.msg();
        this.data = data;
    }

    public Result(ReInter reInter){
        this.code=reInter.code();
        this.msg=reInter.msg();
    }

    //成功方法 不带值
    public static Result success(){
        return new Result(ResultEnum.success);
    }
    //成功方法 带值
    public static Result success(Object data){
        return new Result(ResultEnum.success,data);
    }
    //失败方法不带值
    public static Result error(){
        return new Result(ResultEnum.serverError);
    }

    //失败方法带值
    public static Result error(Object data){
        return new Result(ResultEnum.serverError,data);
    }

    public static Result loginExpire(){
        return new Result(ResultEnum.user_not_login);
    }

}
